//
//  XUtils.h
//  LionLibs
//
//  Created by NicholasXu on 11-5-13.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>


#define PRINT_IS_MAINTHREAD()  NSLog(@"%@ isMainThread:%u addr:0x%x", DEBUG_FUNCTION_NAME, [NSThread isMainThread], (NSUInteger)[NSThread currentThread])
#define LOG_FUNCTION_NAME(x,...) NSLog(@"%s addr:0x%x; %@", __func__, (NSUInteger)self, __VA_ARGS__)

//add by Deheng.Xu 2013.02
#pragma mark - debug macros
#ifndef TRY_BEGIN
#define TRY_BEGIN   @try {
#endif

#ifndef TRY_CATCH
#define TRY_CATCH   }\
@catch (NSException *exception) {\
NSLog(@"%s:%d   %@:\n%@\n", __FUNCTION__, (__LINE__ - 1), [exception name], [exception reason]);\
[exception raise];\
}
#endif


#pragma mark - some c style functions.

//extern inline CGRect CGRectResizeToCGSize(CGRect rect, CGSize size);
//extern inline CGRect CGRectMoveToCGPoint(CGRect rect, CGPoint point);
//extern inline CGSize CGSizeScaleTo(CGSize size, CGFloat factor);
//extern inline CGSize CGSizeScaleToScaleFactors(CGSize size, CGFloat widthFactor, CGFloat heightFactor);

NSString *EncodingFromXMLData(NSData *data);

@interface XUtils : NSObject {
    
}
@property (nonatomic, retain) NSMutableArray * foundSubviews;

+ (void)printArray:(NSArray *)anArray;
+ (void)printArray:(NSArray *)anArray ToDestinateString:(NSString **)aDestString;
+ (void)printDictionary:(NSDictionary *)anDictionary;
+ (XUtils *) instance;
+ (UIImage *)loadImageWithName:(NSString *) name Type:(NSString *) type;
+ (UIImage *)loadImageWithName:(NSString*)imageName;
+ (void)cancelTimer:(NSTimer **)timer;
+ (BOOL)isRetina;
+ (float)osVersion;

//- (NSString *)faviconUrlStringFromHtml:(NSString *)htmlContent andUrl:(NSString *)urlString;
- (NSString *)findCorrectHtmlStringFrom:(NSData *)data andTextEncoding:(NSString *)responseEncoding;
- (NSStringEncoding)findCorrectHtmlStringEncodingFrom:(NSData *)data andTextEncoding:(NSString *)responseEncoding;
- (NSString *)findCorrectHtmlEncodingNameFrom:(NSData *)data;
- (NSDictionary *)encodingSet;

- (NSDictionary *)fontFamily;
- (NSDate*)dateFromString:(NSString*) sDate;
//- (BOOL)checkResponderIfCompressed:(NSDictionary *)responseHeaders;

//- (void)resetDataForTravelingSubviews;
//- (void)travelSubviews:(UIView *) view;
//- (void)findSubview:(UIView *)view WithName:(NSString *)name;
- (NSString *)httpParamsStringByArray:(NSArray*)params;

//char * hex2dec(const char * source);

@end
